package com.bifrost.constant;

/**
 * @author rangf
 * @date 2018/5/10
 */
public enum CouponTypeEnum {
/**
 * DECORATION_COUPON 美容劵
 * DISCOUNT_COUPON 满减券
 * MERCHANT_COUPON 商铺劵
 * CATEGORY_COUPON 品类券
 * SKU_COUPON 单品券
 * ALL_COUPON 通用券
 * SHIPMENT_COUPON 免邮券
 * UPKEEP_COUPON 保养券
 * CASH_COUPON 现金券
 * SERVICE_COUPON
 * */
    CASH_COUPON("CASH_COUPON", "现金券"),
    SERVICE_COUPON("SERVICE_COUPON", "服务券"),
    OFFLINE_COUPON("OFFLINE_COUPON", "线下券");


    private final String code;
    private final String message;

    private CouponTypeEnum(String code , String message){
        this.code = code;
        this.message = message;
    }

    public String getCode(){return code;}

    public String getMessage(){return message;}

    public static CouponTypeEnum getByCode(String code){
        for(CouponTypeEnum e:values()){
            if(e.getCode().equals(code))
                return e;
        }
        return null;
    }

    public static String getMessageByCode(String code){
        if(code == null)
            return null;
        CouponTypeEnum couponTypeEnum = getByCode(code);
        if(couponTypeEnum == null)
            return null;
        return couponTypeEnum.getMessage();
    }

}

class C{
    public static void main(String[] args) {
        System.out.println(CouponTypeEnum.SERVICE_COUPON.name());
    }
}
